<template>
  <div class="recruitment">
    <naviber />
    <div class="table">
      <!-- <img src="@/assets/images/news_table.png" alt /> -->
      <p>{{ text }}</p>
    </div>
    <div class="two_nav clearfloat">
      <div class="two_nav_title">人才招聘</div>
      <div class="item_box">
        <swiper ref="swiper_aboutUs" :options="swiperOption">
          <swiper-slide class="swiper-slide">
            <router-link
              @click.native="onSlide(cate[0].title)"
              :to="{ name: 'zh_social' }"
              class="two_nav_item"
            >
              <span>{{ cate[0].title }}</span>
            </router-link>
          </swiper-slide>
          <swiper-slide class="swiper-slide">
            <router-link
              @click.native="onSlide(cate[1].title)"
              :to="{ name: 'zh_campus' }"
              class="two_nav_item"
            >
              <span>{{ cate[1].title }}</span>
            </router-link>
          </swiper-slide>
          <swiper-slide class="swiper-slide">
            <router-link
              @click.native="onSlide('协力生活')"
              :to="{ name: 'zh_life' }"
              class="two_nav_item"
            >
              <span>协力生活</span>
            </router-link>
          </swiper-slide>
        </swiper>
      </div>
    </div>
    <router-view :cate="cate"></router-view>
    <footer_ />
  </div>
</template>
<script>
import naviber from "../naviber/naviber";
import footer_ from "../footer/footer";
import { job_cate, job_list } from "@/api/recruitment.js";
export default {
  data() {
    return {
      text: "",
      cate: [{ title: null }, { title: null }],
      swiperOption: {
        slidesPerView: "auto",
        spaceBetween: 0,
        // 鼠标控制滚动
        // mousewheel: {
        //   releaseOnEdges: true
        // },
        //设置点击箭头
        navigation: {
          nextEl: "#swiper-button-next",
          prevEl: "#swiper-button-prev"
        },
        observer: true, //修改swiper自己或子元素时，自动初始化swiper
        observeParents: false, //修改swiper的父元素时，自动初始化swiper
        onSlideChangeEnd: function(swiper) {
          swiper.update();
          mySwiper.startAutoplay();
          mySwiper.reLoop();
        },
        //鼠标变成抓手型
        grabCursor: true
        //开启鼠标滚轮控制Swiper切换
        // mousewheel: true,
      }
    };
  },
  components: {
    naviber,
    footer_
  },
  created() {
    // if (this.$store.state.headTitle.equipment == "mobile") {
    //   this.swiperOption.slidesPerView = 4;
    // }
  },
  watch: {
    "$route.query.titleText": {
      deep: true,
      handler: function(newValue, oldValue) {
        this.text = newValue;
      }
    }
    // "$store.state.headTitle.equipment": {
    //   deep: true,
    //   handler: function(newValue, oldValue) {
    //     if (newValue == "pc") {
    //       this.$refs.swiper_aboutUs.$swiper.params.slidesPerView = 6;
    //     } else {
    //       this.$refs.swiper_aboutUs.$swiper.params.slidesPerView = 4;
    //     }
    //     // this.$refs.swiper.update();
    //   }
    // }
  },
  mounted() {
    //   console.log(this.$route)
    try {
      this.text = this.$route.query.titleText;
    } catch (error) {
    //   this.text = "社会招聘";
    }
    job_cate().then(res => {
      this.cate = res.data.data.CHS;
    });
  },
  methods: {
    onSlide(text) {
      this.text = text;
    }
  }
};
</script>
<style scoped src="./sass/recruitment.css"></style>
